package com.xiaoxu.privatechat.config.admin;

import com.xiaoxu.privatechat.constant.RuntimeConstant;
import com.xiaoxu.privatechat.interceptor.admin.AdminAuthorityInterceptor;
import com.xiaoxu.privatechat.interceptor.admin.AdminLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author xiaoxu
 * @description 用来配置拦截器的配置类
 * @date 2023/2/13
 */
@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Resource
    private AdminLoginInterceptor adminLoginInterceptor;

    @Resource
    private AdminAuthorityInterceptor adminAuthorityInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminLoginInterceptor).addPathPatterns("/**").excludePathPatterns(RuntimeConstant.loginExcludePathPatterns);
        registry.addInterceptor(adminAuthorityInterceptor).addPathPatterns("/**").excludePathPatterns(RuntimeConstant.authorityExcludePathPatterns);
    }

}
